from common.base import Base, By
from common.functions import backhost


class Backstage(Base):
    # 后台路径
    backstage_url = backhost

    def backstage_login(self):
        # 后台登录
        self.click((By.CLASS_NAME, 'btn-tab'))

    def input_username(self, username):
        # 定位账号输入框，输入数据
        self.find_element((By.NAME, 'username')).send_keys(username)

    def input_password(self, password):
        # 定位密码输入框，输入数据
        self.find_element((By.NAME, 'password')).send_keys(password)

    def btn_login(self):
        # 定位登录按钮，点击
        self.click((By.CLASS_NAME, 'btn-a'))

    def next_login(self):
        # 获取登陆后的用户名
        return self.get_element_text((By.XPATH, '//*[@id="foot-div"]/a'))

    def click_X(self):
        # 点击xx
        self.click((By.XPATH, '//*[@id="panelCloud"]/div[1]/span'))

    def menu_frame(self):
        # 定位指定的frame
        frame = self.find_element((By.ID, 'menu-frame'))
        # 切换frame
        self.driver.switch_to.frame(frame)
